using System.Collections.Generic;
using Holoville.HOTween;
using Holoville.HOTween.Core;
using UnityEngine;

public class CarJumpButton : MonoBehaviour
{
	public static CarJumpButton instance;

	public List<UISprite> cooldownSprites;

	private float jumpCooldownTime = 2.4f;

	[HideInInspector]
	public float fillAmount;

	private void Awake()
	{
		instance = this;
	}

	public void OnJump()
	{
		if (PlayerBehavior.MyPlayer == null || PlayerBehavior.MyPlayer.currentCar == null || PlayerBehavior.MyPlayer.currentCar.onJump)
		{
			return;
		}
		PlayerBehavior.MyPlayer.currentCar.onJump = true;
		fillAmount = 0f;
		HOTween.To(this, jumpCooldownTime, new TweenParms().Prop("fillAmount", 1).UpdateType(UpdateType.TimeScaleIndependentUpdate).OnUpdate((TweenDelegate.TweenCallback)delegate
		{
			cooldownSprites.ForEach(delegate(UISprite sprite)
			{
				sprite.fillAmount = fillAmount;
			});
		})
			.OnComplete((TweenDelegate.TweenCallback)delegate
			{
				if (PlayerBehavior.MyPlayer != null && PlayerBehavior.MyPlayer.currentCar != null)
				{
					PlayerBehavior.MyPlayer.currentCar.onJump = false;
				}
			}));
	}
}
